import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { AccountSubjectVO, AccountSubjectForm, AccountSubjectQuery } from "@/api/budget/accountSubject/types";

/**
 * 查询会计科目管理列表
 * @param query
 * @returns {*}
 */

export const listAccountSubject = (query?: AccountSubjectQuery): AxiosPromise<AccountSubjectVO[]> => {
  return request({
    url: "/budget/account/list",
    method: "post",
    data: query
  });
};

/**
 * 查询会计科目管理详细
 * @param id
 */
export const getAccountSubject = (id: string | number): AxiosPromise<AccountSubjectVO> => {
  return request({
    url: "/budget/account/" + id,
    method: "get"
  });
};

/**
 * 新增会计科目管理
 * @param data
 */
export const addAccountSubject = (data: AccountSubjectForm) => {
  return request({
    url: "/budget/account",
    method: "post",
    data: data
  });
};

/**
 * 修改会计科目管理
 * @param data
 */
export const updateAccountSubject = (data: AccountSubjectForm) => {
  return request({
    url: "/budget/account",
    method: "put",
    data: data
  });
};

/**
 * 删除会计科目管理
 * @param id
 */
export const delAccountSubject = (id: string | number | Array<string | number>) => {
  return request({
    url: "/budget/account/" + id,
    method: "delete"
  });
};

/**
 * 会计科目下拉
 */
export const getAccountList = (): AxiosPromise<AccountSubjectVO[]> => {
  return request({
    url: "/budget/account/getAccountList",
    method: "get"
  });
};
